package com.zzjson.thread.condition;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson.thread.condition</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年08月21日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class ConditionAwait extends Thread {
	private Lock lock;
	private Condition condition;

	public ConditionAwait(Lock lock, Condition condition) {
		this.lock = lock;
		this.condition = condition;
	}


	@Override
	public void run() {
		lock.lock();
		System.out.println("before await");
		try {
			condition.await();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		System.out.println("after await");
		lock.unlock();
	}
}